package com.mywang.weitravel.modules.read;

import android.content.Intent;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSnapHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.mywang.weitravel.R;
import com.mywang.weitravel.adapter.ReadChinaAdapter;
import com.mywang.weitravel.base.BaseActivity;
import com.mywang.weitravel.model.ReadDetailBean;
import com.mywang.weitravel.modules.ReadTypeBean;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by wangmingyun on 2019/12/11.
 */
public class ReadChinaDetailActivity extends BaseActivity<ReadChinaPresenter> implements ReadChinaContract.View {

    @BindView(R.id.iv_title_back)
    ImageView ivTitleBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.rv_list)
    RecyclerView rvList;

    private ReadChinaAdapter adapter;

    @Override
    protected void initView() {
        tvTitle.setText("阅读中国");
        Intent intent = getIntent();
        mPresenter.getDetail(intent.getStringExtra("id"));
    }

    @Override
    protected ReadChinaPresenter initPresenter() {
        return new ReadChinaPresenter(this);
    }

    @Override
    protected int getActivityLayoutID() {
        return R.layout.activity_read_china_detail;
    }

    @Override
    public void onSuccess(List<ReadTypeBean> list) {

    }

    @Override
    public void onDetailSuccess(List<ReadDetailBean> list) {
        adapter = new ReadChinaAdapter(this, list);
        rvList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        rvList.setAdapter(adapter);
        new LinearSnapHelper().attachToRecyclerView(rvList);
    }

    @OnClick(R.id.iv_title_back)
    public void onViewClicked() {
        finish();
    }

}
